package com.wang.mylambda;

import java.util.function.IntBinaryOperator;

/**
 * @author yandong
 */
public class LambdaDemo2 {
    public static void main(String[] args) {
        // 传统写法: 匿名内部类
        calculateNum(new IntBinaryOperator() {
            @Override
            public int applyAsInt(int left, int right) {
                return left + right;
            }
        });

        // Lambda表达式写法:
        calculateNum((left, right) -> left + right);
    }

    public static void calculateNum(IntBinaryOperator  operator) {
        int a = 10;
        int b = 20;
        System.out.println(operator.applyAsInt(a, b));
    }
}
